<?php
require_once 'database.php';

define("MYSQL_DATEFORMAT", "Y-m-d");
define("JQUERY_DATEFORMAT", "m/d/Y");

/**
 * Returns true if the user is logged in
 */
function isUserLoggedIn(){
	
	if($_SESSION['user'] != null){
		return true;
	}
	
	return false;
}

/**
 * Redirects the user based on if theyre on the correct page
 * @param unknown $strUsername
 */
function redirectBasedOnUser($strUsername, $strCurrentPage){
	if($strCurrentPage == 'index' && $_SESSION['user'] != null){
		//Redirect to home page
	} 
	
}

function logout(){
	session_unset();
	
	header("Location: /index.php");
}

/**
 * Gets the user id from the database based on the username
 * @param unknown $strUsername
 */
function getUserIdFromUsername($strUsername){
	$dbUsers = mysql_query("SELECT * FROM account WHERE username= '$strUsername'")
	or die("Problem reading table: " . mysql_error());
	$row = mysql_fetch_row($dbUsers);
	$intAccountId = $row[0];
	return $intAccountId;
}